<?php
include "../../../lib/list.php";
if ($s_no = $_GET['s_no']){
	$sear_char .= " AND s_no = $s_no";
}
if ($sg_no = $_GET['sg_no']){
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/list.css" type="text/css"></link>
<link rel="stylesheet" href="../../../css/insert.css" type="text/css"></link>
<link rel="stylesheet" href="../../../css/table.blue.sorter.css" type="text/css" media="print, projection, screen"></link>
<link rel="stylesheet" href="../../../css/jquery.tablesorter.pager.css"	type="text/css" media="print, projection, screen"></link>

<script type="text/javascript" src="../../../js/jquery-1.2.6.js"></script>
<script type="text/javascript"	src="../../../js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" src="../../../js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="../../../js/list.js"></script>
<script type="text/javascript">
	$(function(){
		$("select[name='sg_no']").change(function(){
		    var sg_no = $("select[name='sg_no']").attr('value');
		    $.get('../../../lib/select.php?sg_no='+sg_no,function(res){
		        $("select[name='s_no']").html(res);
		    });
		});
		
		$("table")
			.tablesorter({headers: {             
	     		   		0: {               
	        		     // 정렬선택 안함
	        		     sorter: false         
	        		    }         
	        		   }, widthFixed: true, widgets: ['zebra'] })
			.tablesorterPager({container: $("#pager")});
	});

	function movepage(url,get,value){
		var sg_no = document.getElementsByName('sg_no')[0].value;
		location.href = url+"?"+get+"="+value+"&sg_no="+sg_no;
	}
	</script>
</head>
<body>
	<div style="width: 1024px; padding: 10px;">
		<div
			style="border-bottom: 1px solid #e8e8e8; text-align: left; font-size: 12px; margin-bottom: 12px; color: #9a9a9a">:::
			재고 관리&nbsp;⇒&nbsp;재고 확인 갱신</div>
			<div style="float: left; padding: 5px; font-size:11px;">
						<select name='sg_no' class="default">
						<option value="-3">:: 점포그룹 선택 ::</option>
						<?
						$qry = "SELECT * FROM uatp_shopgroup order by no DESC";
						$query = DBquery($qry);
						while($list = mysql_fetch_array($query)){
							?>
						<option value="<?=$list['no']?>"<?if($list['no']==$sg_no)echo " selected";?>><?=$list['name']?></option>
						<?
						}
						mysql_close();
						?>
						</select>
						
						<select name='s_no' class="default" onChange="movepage('stview.php','s_no',this.value);";>
							<option value="">:: 점포 선택 ::</option>
							<?
							if($sg_no){
								$qry = "SELECT * FROM uatp_shopinfo WHERE sg_no = $sg_no order by no DESC";
								$query = DBquery($qry);
								while($list = mysql_fetch_array($query)){
									?>
														<option value="<?=$list['no']?>"<?if($list['no']==$s_no)echo " selected";?>><?=$list['name']?></option>
														<?
														}
														mysql_close();
							}
							?>
						</select>
			</div>
			<div style="float: right; padding: 5px; font-size:11px;">
			<?
			$query = "SELECT * FROM uatp_stocktmp";
				$count_tmp = DBnumrows($query);
				if($count_tmp){
					echo "<tr>
					<td></td>
					<td><a href='tmpview.php'><center><b><img src='../../../image/new.gif' style='border:0px;'/>&nbsp; 대기 중인 제품 제고가 '$count_tmp' 개 있습니다.</center></b></a></td>
					</tr>";
				}
				?>
			</div>
		<form name="view" method="post">
			<input type="hidden" value="" name="mode" />
			<table cellspacing="1" class="tablesorter">
				<thead>
					<tr>
						<th width="30px">no</th>
						<th>점포</th>
						<th>전표번호</th>
						<th>상품</th>
						<th>관리자</th>
						<th>날짜</th>
					</tr>

				</thead>
				<tfoot>
					<tr>
						<th width="30px">no</th>
						<th>점포</th>
						<th>전표번호</th>
						<th>상품</th>
						<th>관리자</th>
						<th>날짜</th>
					</tr>
				</tfoot>
							
				<tbody>

		<?		
						$query = "SELECT *,count(*) AS 'count' FROM uatp_stockreview WHERE 1 $sear_char group by date order by date DESC";
						$total = DBnumrows($query);
						$result = DBquery($query);
						for($i=1; $list = mysql_fetch_array($result); $i++){
							$bunho = $total - ( $i + $cline) + 1;
							
									$name	=	DBarray("select * from uatp_shopinfo where no = $list[s_no]");
									$shop_name	=	$name['name'];
									
									$product = DBarray("SELECT * FROM uatp_product WHERE no = $list[p_no]");
									$count = $list['count']-1;
									
									$count > 0?$count = " 외 ".$count."&nbsp;개":$count = "";
							?>
							<tr>
								<td align="center" width="30px"><?=$bunho?></td>
								<td><?=$shop_name?></td>
								<td><b><a href="javascript:movepage('stdetail.php','date','<?=$list['date']?>');"><?=date('ymd-his',strtotime($list['date']))?></a></b></td>
								<td>
								&nbsp;<?echo $product['productname'].$count;
								?>
								</td>
								<td><?=$list['admin_name']?></td>
								<td><?=date('Y-m-d',strtotime($list['date']))?></td>
							</tr>
<?php 
}
	mysql_free_result($result);
?>
			</tbody>
			</table>
		</form>
		<div id="pager" class="pager">
			<form>
				<img src="../../../image/first.png" class="first" /> <img
					src="../../../image/prev.png" class="prev" /> <input type="text"
					class="pagedisplay" /> <img src="../../../image/next.png"
					class="next" /> <img src="../../../image/last.png" class="last" />
				<select class="pagesize">
					<option selected="selected" value="10">10</option>
					<option value="20">20</option>
					<option value="30">30</option>
					<option value="40">40</option>
				</select>
			</form>
		</div>
	</div>
</body>
</html>